﻿package org.aquiferserver.client.flex
{
	import org.aquiferserver.common.Player;
	
	/**
	 * ...
	 * @author Seth Albanese
	 * @version $Id: SimpleGameState.as 60 2009-06-15 08:47:09Z salbanese0080@gmail.com $
	 */
	public class SimpleGameState implements GameState
	{
		
		private var properties:Array = new Array();
		private var _id:int;
		private var peerList:Array = new Array();
		private var local:Player;
		
		public function setProperty( prop:String, val:Object ) : void
		{
			properties[ prop ] = val;
		}
		
		public function getProperty( prop:String ) : Object
		{
			return properties[ prop ];
		}
		
		public function deleteProperty( prop:String ) : Object
		{
			var p:Object = properties[ prop ];
			properties.splice( properties.indexOf( prop ), 1 );
			return p;
		}
		
		public function getPropertyList() : Array
		{
			return properties;
		}
		
		public function get peers() : Array
		{
			return peerList;
		}
		
		public function set peers( peers:Array ) : void
		{
			peerList = peers;
		}
		
		public function addPeer( p:Player ) : void
		{
			if ( peerList.indexOf( p ) == -1 )
			{
				peerList.push( p );
			}			
		}
		
		public function removePeer( p:Player ) : void
		{
			peerList.splice( peerList.indexOf( p ), 1 );
		}
		
		public function set id( id:int ) : void
		{
			_id = id;
		}
		
		public function get id() : int
		{
			return _id;
		}
		
		public function set localPlayer( p:Player ) : void
		{
			local = p;
		}
		
		public function get localPlayer( ) : Player
		{
			return local;
		}
	}
	
}